package cc;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;

import oracle.to.mysql.utils.SqlUtils;

public class CA11_RC {

	private static Logger log = Logger.getLogger(" ");
	static {
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			log.error("驱动加载异常：" + e.getMessage());
		}
	}

	public static void main(String[] args) throws SQLException, IOException {
		long time = System.currentTimeMillis();
		Connection connMysql = DriverManager.getConnection(SqlUtils.getMySqlUrl());
		Statement csMysql = connMysql.createStatement();
		ResultSet rs = csMysql.executeQuery("select aca111,aca112 from ca11_rc");
		Connection connOracle = DriverManager.getConnection(SqlUtils.ORACLE_URL, SqlUtils.ORACLE_USER, SqlUtils.ORACLE_PWD);
		Statement csOracle = connOracle.createStatement();
		csOracle.execute("truncate table CA11_rc");
		int index = 0;
		while (rs.next()) {
			String aca111 = rs.getString("aca111");
			String aca112 = rs.getString("aca112");
			csOracle.execute("insert into CA11_rc(aca111,ACA112) values('"+aca111+"','"+aca112+"')");
			index++;
		}
		csMysql.close();
		csOracle.close();
		connOracle.close();
		connMysql.close();
		log.info("条数："+index+"，耗时:" + (System.currentTimeMillis() - time) + "ms");
	}
}